package com.studio77.guessLyric.sprite;

import com.studio77.guessLyric.R;
import com.studio77.guessLyric.core.GameSystem;
import com.studio77.guessLyric.scene.GameScene;
import com.wiyun.engine.nodes.Button;
import com.wiyun.engine.nodes.Label;
import com.wiyun.engine.nodes.Node;
import com.wiyun.engine.sound.AudioManager;
import com.wiyun.engine.types.WYColor3B;

public class DaanItem extends Node {
	Button btnBackground;
	Label lblContent;

	public String content = "";
	public boolean isSetDaan = false;

	public DaanItem() {
		btnBackground = Button.make(R.drawable.daan_item, R.drawable.daan_item,
				this, "onItemClicked");
		btnBackground.setClickScale(1.05f);
		this.addChild(btnBackground);

		lblContent = Label.make("", 35);
		lblContent.setTouchEnabled(false);
		lblContent.setColor(WYColor3B.make(0, 0, 0));
		this.addChild(lblContent);
	}

	public void onItemClicked() {
		// TODO 通知控件
		AudioManager.playEffect(R.raw.cancel);
		if (isSetDaan) {
			clearDaan();
			GameScene.make().getLayer().daanControl.onItemCleaned(this);
		}
	}

	public void setDaan(String str) {
		isSetDaan = true;
		lblContent.setText(str);
		content = str;
	}

	public void clearDaan() {
		isSetDaan = false;
		lblContent.setText("");
		content = "";
	}

}
